//
//  WTRegisterView.m
//  OneDay
//
//  Created by lanou on 16/1/19.
//  Copyright © 2016年 小明. All rights reserved.
//

#import "WTRegisterView.h"


#define kMargin 10 * kRelativeLength_X

@implementation WTRegisterView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 用户
        _userImageV = [[UIImageView alloc]initWithFrame:CGRectMake(kMargin, 30 * kRelativelength_Y, 20 * kRelativeLength_X, 20 * kRelativelength_Y)];
        [self addSubview:_userImageV];
        
        _userTF = [[UITextField alloc]initWithFrame:CGRectMake(_userImageV.right + 15 * kRelativeLength_X, _userImageV.top, kScreenWidth - _userImageV.right - 15 * kRelativeLength_X, _userImageV.height)];
        _userTF.clearButtonMode = UITextFieldViewModeAlways;
        _userTF.delegate = self;
        [self addSubview:_userTF];
        
        UIImageView * bottoViewOne = [[UIImageView alloc]initWithFrame:CGRectMake(0, _userImageV.bottom + 19 * kRelativelength_Y, kScreenWidth, kRelativelength_Y)];
        bottoViewOne.backgroundColor = [UIColor grayColor];
        [self addSubview:bottoViewOne];
        
        
        
        
        // 密码
        _passwordImageV = [[UIImageView alloc]initWithFrame:CGRectMake(kMargin, bottoViewOne.bottom + 20 * kRelativelength_Y, 20 * kRelativeLength_X, 20 * kRelativelength_Y)];
        [self addSubview:_passwordImageV];
        
        _passwordTF = [[UITextField alloc]initWithFrame:CGRectMake(_passwordImageV.right + 15 * kRelativeLength_X, _passwordImageV.top, kScreenWidth - _passwordImageV.right - 15 * kRelativeLength_X, _passwordImageV.height)];
        _passwordTF.delegate = self;
        _passwordTF.clearButtonMode = UITextFieldViewModeAlways;
        _passwordTF.secureTextEntry = YES;
        [self addSubview:_passwordTF];
        
        UIImageView * bottoViewTwo = [[UIImageView alloc]initWithFrame:CGRectMake(0, _passwordImageV.bottom + 19 * kRelativelength_Y, kScreenWidth, kRelativelength_Y)];
        bottoViewTwo.backgroundColor = [UIColor grayColor];
        [self addSubview:bottoViewTwo];
        
        
        
        // 确认密码
        _repasswordImageV = [[UIImageView alloc]initWithFrame:CGRectMake(kMargin, bottoViewTwo.bottom + 20 * kRelativelength_Y, 20 * kRelativeLength_X, 20 * kRelativelength_Y)];
        [self addSubview:_repasswordImageV];
        
        _repasswordTF = [[UITextField alloc]initWithFrame:CGRectMake(_repasswordImageV.right + 15 * kRelativeLength_X, _repasswordImageV.top, kScreenWidth - _repasswordImageV.right - 15 * kRelativeLength_X, _repasswordImageV.height)];
        _repasswordTF.delegate = self;
        _repasswordTF.clearButtonMode = UITextFieldViewModeAlways;
        _repasswordTF.secureTextEntry = YES;
        [self addSubview:_repasswordTF];
        
        UIImageView * bottoViewThr = [[UIImageView alloc]initWithFrame:CGRectMake(0, _repasswordImageV.bottom + 19 * kRelativelength_Y, kScreenWidth, kRelativelength_Y)];
        bottoViewThr.backgroundColor = [UIColor grayColor];
        [self addSubview:bottoViewThr];

        
        // 验证按钮
        _confirmButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _confirmButton.frame = CGRectMake(kScreenWidth - 150 * kRelativeLength_X, bottoViewThr.bottom + 10 * kRelativelength_Y, 140 * kRelativeLength_X, 30 * kRelativelength_Y);
        _confirmButton.backgroundColor = [UIColor grayColor];
        [_confirmButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
        [self addSubview:_confirmButton];
        
        // 验证码
        _confirmTF = [[UITextField alloc]initWithFrame:CGRectMake(_confirmButton.left - 155 * kRelativeLength_X, _confirmButton.top, 150 * kRelativeLength_X, _confirmButton.height)];
        
        _confirmTF.textColor = [UIColor blackColor];
        _confirmTF.borderStyle = UITextBorderStyleRoundedRect;
        _confirmTF.keyboardType = UIKeyboardTypeNumberPad;
        [self addSubview:_confirmTF];
        
        
        
        // 注册
        _registerButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _registerButton.frame = CGRectMake((kScreenWidth - 200 * kRelativeLength_X) / 2, _confirmTF.bottom + kMargin, 200 * kRelativeLength_X, 60 * kRelativelength_Y);
        _registerButton.backgroundColor = [UIColor grayColor];
        [_registerButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
        [self addSubview:_registerButton];
        
        
        
        
        
    }
    return self;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
 
    [textField resignFirstResponder];
    return YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
